//
//  HLMineFooterView.m
//  YueYue
//
//  Created by hulu001 on 2023/5/19.
//

#import "HLMineFooterView.h"
#import <SDCycleScrollView/SDCycleScrollView.h>

@interface HLMineFooterView ()<SDCycleScrollViewDelegate>

@property (nonatomic, strong) SDCycleScrollView *cycleScrollView;

@end


@implementation HLMineFooterView


- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = UIColorClear;
        self.contentView.backgroundColor = UIColorClear;
        [self setupView];
    }
    return self;
}


- (void)setupView {
    self.containerView = [[UIView alloc] init];
    _containerView.backgroundColor = UIColorWhite;
    _containerView.layer.masksToBounds = YES;
    _containerView.layer.cornerRadius = 8;
    [self.contentView addSubview:_containerView];
    [_containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.mas_equalTo(-8);
        make.height.mas_equalTo(16);
    }];
    
    self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, 80) delegate:self placeholderImage:UIImageMake(@"avatar")];
    _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    _cycleScrollView.layer.masksToBounds = YES;
    _cycleScrollView.layer.cornerRadius = 8;
    _cycleScrollView.backgroundColor = HLBackgroundColor;
    [self.contentView addSubview:_cycleScrollView];
    [_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_containerView.mas_bottom).offset(14);
        make.left.right.equalTo(_containerView);
        make.height.mas_equalTo(80);
        make.bottom.mas_equalTo(0);
    }];
}

- (void)setBanners:(NSArray<HLBannerModel *> *)banners
{
    _banners = banners;
    
   NSArray <NSString *>*urls = [banners qmui_mapWithBlock:^NSString *(HLBannerModel * item, NSInteger index) {
        return item.bannerImgUrl;
    }];
    _cycleScrollView.imageURLStringsGroup = urls;
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    HLBannerModel *model = self.banners[index];
    [model jumpTargetWithController:self.qmui_viewController];
}

+ (NSString *)identifyCell
{
    return NSStringFromClass([self class]);
}

@end
